package com.fan.shop.services;

import java.util.List;

import javax.inject.Inject;
import javax.inject.Named;

import org.springframework.transaction.annotation.Transactional;

import com.fan.shop.dao.StockReqLineDao;
import com.fan.shop.domain.StockReqLine;
import com.fan.shop.model.userclass.StockReqLineUserClass;



@Named("stockReqLineService")
@Transactional(readOnly = true)
public class StockReqLineServiceImpl implements StockReqLineService {
	@Inject
	@Named("stockReqLineDao")
	private StockReqLineDao stockReqLineDao;

	public StockReqLineDao getStockReqLineDao() {
		return stockReqLineDao;
	}

	public void setStockReqLineDao(StockReqLineDao stockReqLineDao) {
		this.stockReqLineDao = stockReqLineDao;
	}

	@SuppressWarnings("rawtypes")
	public List getList() {
		return stockReqLineDao.getAllStockReqLines();
	}

	public int getColumnsSize() {
		return getColumnNames().size();
	}

	public StockReqLineUserClass copy(Object obj) {
		StockReqLine stockReqLine = (StockReqLine)obj;
		
		StockReqLineUserClass stockReqLineUserClass = new StockReqLineUserClass();
		stockReqLineUserClass.setRequisitionNo(stockReqLine.getId().getRequisitionNo());
		stockReqLineUserClass.setItemCode(stockReqLine.getId().getItemCode());
		stockReqLineUserClass.setLineStatus(stockReqLine.getLineStatus());
		stockReqLineUserClass.setOfficerCode(stockReqLine.getOfficerCode());
		stockReqLineUserClass.setPrice(stockReqLine.getPrice());
		stockReqLineUserClass.setQty(stockReqLine.getQty());
		stockReqLineUserClass.setStoreCode(stockReqLine.getStoreCode());
		stockReqLineUserClass.setTransactionDate(stockReqLine.getTransactionDate());
		
		return stockReqLineUserClass;
	}

	public StockReqLine getStockReqLine(String requisitionNo, String itemCode) {
		return stockReqLineDao.getStockReqLine(requisitionNo, itemCode);
	}

	public List<StockReqLine> getAllStockReqLines() {
		return stockReqLineDao.getAllStockReqLines();
	}

	public int getSize() {
		return stockReqLineDao.getSize();
	}

	@Transactional(readOnly = false)
	public void addStockReqLine(StockReqLine stockReqLine) {
		stockReqLineDao.addStockReqLine(stockReqLine);

	}

	@Transactional(readOnly = false)
	public void updateStockReqLine(StockReqLine stockReqLine) {
		stockReqLineDao.updateStockReqLine(stockReqLine);

	}

	@Transactional(readOnly = false)
	public void deleteStockReqLine(StockReqLine stockReqLine) {
		stockReqLineDao.deleteStockReqLine(stockReqLine);

	}

	public boolean hasStockReqLine(String requisitionNo, String lineNo) {
		return stockReqLineDao.hasStockReqLine(requisitionNo, lineNo);
	}

	public List<String> getColumnNames() {
		return stockReqLineDao.getColumnNames();
	}

}
